package com.job.ZhangMeng.Homework0702;

/**
 * 2022.07.02  冒泡排序
 * 张孟
 */

class MyTool1{
    public static int[] sort1(int[] x)  //冒泡排序
    {
        int i, j, mid;
        for (i = 1; i < x.length; i++)  //比较length-1轮
        {
            for (j = 0; j < x.length - i; j++) {  //每轮比较length-1-i次
                if (x[j] < x[j + 1]) {
                    mid = x[j];
                    x[j] = x[j + 1];
                    x[j + 1] = mid;
                }
            }
        }
        return x;
    }
}

public class Homework0702_A {

    public static void main(String[] args) {
        int i;
        int[] arr={2,10,97,8,18,51,34};
        MyTool1.sort1(arr);
        for(i=0;i<arr.length;i++)//遍历并输出
            System.out.print(arr[i]+" ");
    }

}
